<script>
    function Imprimer(id) {
        $.ajax({
            url: '{{path('gds_vente_bon_facture_saved')}}',
            type: "POST",
            data: 'id='+id,
            success: function(data) {
                $.msgBox({
                    title: "Facture",
                    content: "Enregistrement Effectué avec succés",
                    type: "info",
                    buttons: [{value: "OK"}],
                    success: function(result) {
                        location.reload();
                    }
                });
            }
        })
    }
    function time() {
        var time = new Date($.now())
        var h = time.getHours() // 0-24 format
        var m = time.getMinutes()
        var s = time.getSeconds()
        $('#heure').val(s + m * 60 + h * 3600)
        if (h < 10)
            h = '0' + h
        if (m < 10)
            m = '0' + m
        if (s < 10)
            s = '0' + s
        $('#now').val(h + ':' + m + ':' + s)
    }
    function TriTab(tab, tab2) {
        var n = tab.length;
        var continuer = true;
        var i = 0;
        var iter = 0;
        while (continuer) {
            iter++;
            continuer = false;
            for (i = 0; i < n - 1; i++) {
                if (Math.max(tab[i], tab[i + 1]) != tab[i + 1]) {
                    inverser(tab, i, i + 1, tab2);
                    continuer = true;
                }
            }
        }
        return tab2;
    }
    function inverser(tab, i, j, tab2) {
        var temp = tab[i];
        var base = tab2[i]['base']
        var montant = tab2[i]['montant']
        var tva = tab2[i]['tva']
        tab[i] = tab[j];
        tab[j] = temp;
        tab2[i]['base'] = tab2[j]['base']
        tab2[j]['base'] = base
        tab2[i]['montant'] = tab2[j]['montant']
        tab2[j]['montant'] = montant
        tab2[i]['tva'] = tab2[j]['tva']
        tab2[j]['tva'] = tva
    }
</script>